package com.tele.controller;

import com.tele.domain.Solution;
import com.tele.service.ints.SolutionService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import javax.annotation.Resource;

/**
 * (Solution)表控制层
 *
 * @author makejava
 * @since 2023-08-23 14:49:43
 */
@RestController
@RequestMapping("solution")
public class SolutionController{
    /**
     * 服务对象
     */
    @Resource
    private SolutionService solutionService;

    /**
     * 查询所有数据
     *
     * @return 实例对象集合
     */
    @GetMapping
    public ResponseEntity<List> queryAll() {
        return ResponseEntity.ok(this.solutionService.queryAll());
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    public ResponseEntity<Solution> queryById(@PathVariable("id") Long id) {
        return ResponseEntity.ok(this.solutionService.queryById(id));
    }

    /**
     * 新增数据
     *
     * @param solution 实体
     * @return 新增结果
     */
    @PostMapping
    public ResponseEntity<Solution> add(Solution solution) {
        return ResponseEntity.ok(this.solutionService.insert(solution));
    }

    /**
     * 编辑数据
     *
     * @param solution 实体
     * @return 编辑结果
     */
    @PutMapping
    public ResponseEntity<Solution> edit(Solution solution) {
        return ResponseEntity.ok(this.solutionService.update(solution));
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @DeleteMapping
    public ResponseEntity<Boolean> deleteById(Long id) {
        return ResponseEntity.ok(this.solutionService.deleteById(id));
    }

}


